﻿@model Kooboo.CMS.Content.Models.Repository
@using Kooboo.CMS.Content.Services;
@using Kooboo.CMS.Common.Runtime;
@{
    var routeValues = ViewContext.RequestContext.AllRouteValues().Merge("repositoryName", Model.Name);

    var schemaManager = EngineContext.Current.Resolve<SchemaManager>();
    var textFolderManager = EngineContext.Current.Resolve<TextFolderManager>();
    var siteManager = EngineContext.Current.Resolve<SiteManager>();

    var contentTypes = schemaManager.All(Model, "").Count();
    var textFolders = textFolderManager.All(Model, "").Count();
    var sites = siteManager.All().Select(it => it.AsActual()).Where(it => it.Repository.EqualsOrNullEmpty(Model.Name, StringComparison.OrdinalIgnoreCase)).Count();
}
<div class="content-block database">

    <div class="content-block-header @(sites > 0 ? "inused" : "notused")">
        @Html.ActionLink(string.IsNullOrEmpty(Model.DisplayName) ? Model.Name : Model.DisplayName, "Guide", "Repository", routeValues, new RouteValueDictionary(new { title = Model.Name }))
        <input type="radio" name="select" class="select" value="@Model.UUID" id="@Model.UUID"  data-id-property="UUID"><label for="@Model.UUID"></label><span class="corner"></span>
    </div>

    <ul>
        <li>
            @("Content types:") @(contentTypes)
        </li>

        <li>
            @("Text folders:") @(textFolders)
        </li>
        <li>
            @("Sites in use:") @sites
        </li>
    </ul>

</div>
